/******************************************************************************
 * @File name   :      CouponBatchServiceImpl.java
 *
 * @Author      :      JIZHANGS
 *
 * @Date        :      Sep 8, 2015
 *
 * @Copyright Notice: 
 * Copyright (c) 2015 Capgemini, Inc. All  Rights Reserved.
 * This software is published under the terms of the Capgemini Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * Sep 8, 2015 3:40:19 PM        JIZHANGS     1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.crmdp.dealer.coupon.service.impl;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.tools.ant.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cap.bts.commonfunc.common.constant.SmsTemplateNoConstants;
import com.cap.bts.commonfunc.common.constant.SmsTemplateVariable;
import com.cap.bts.commonfunc.common.dto.SmsContentDetailDto;
import com.cap.bts.commonfunc.common.util.UserUtil;
import com.cap.bts.crmdp.dealer.card.util.CSVUtils;
import com.cap.bts.crmdp.dealer.coupon.constants.CouponConstants;
import com.cap.bts.crmdp.dealer.coupon.dao.ICouponBatchDao;
import com.cap.bts.crmdp.dealer.coupon.dao.ICouponBatchLineDao;
import com.cap.bts.crmdp.dealer.coupon.dao.ICouponDao;
import com.cap.bts.crmdp.dealer.coupon.dao.ICouponRedeemDao;
import com.cap.bts.crmdp.dealer.coupon.dao.ITicKetDefineDao;
import com.cap.bts.crmdp.dealer.coupon.domain.Coupon;
import com.cap.bts.crmdp.dealer.coupon.domain.CouponBatch;
import com.cap.bts.crmdp.dealer.coupon.domain.CouponBatchLine;
import com.cap.bts.crmdp.dealer.coupon.domain.CouponRedeem;
import com.cap.bts.crmdp.dealer.coupon.domain.Ticket;
import com.cap.bts.crmdp.dealer.coupon.dto.CouponBatchDto;
import com.cap.bts.crmdp.dealer.coupon.dto.CouponForMARSDto;
import com.cap.bts.crmdp.dealer.coupon.dto.RedeemCouponSubmitDto;
import com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService;
import com.cap.bts.crmdp.dealer.coupon.service.ICouponEligibilityService;
import com.cap.bts.crmdp.dealer.mars.dto.AjaxResponse;
import com.cap.bts.crmdp.dealer.mars.dto.CouponRedeemtionDto;
import com.cap.bts.crmdp.dealer.member.dao.IMaintainCarPlateDao;
import com.cap.bts.crmdp.dealer.member.dao.IMaintainMemberDao;
import com.cap.bts.crmdp.dealer.member.domain.CarPlateInfo;
import com.cap.bts.crmdp.dealer.member.domain.MemberInfo;
import com.cap.bts.crmdp.dealer.redemption.service.impl.RedemptionServiceImpl;
import com.cap.bts.crmdp.webservice.dto.MarsResultDto;
import com.cap.bts.crmdp.webservice.mars.client.CRM2MARS;
import com.cap.bts.framework.common.exception.AppException;
import com.cap.bts.framework.common.util.Utils;
import com.cap.bts.framework.sms.service.ISmContentService;

/**
 * 优惠券活动批次
 */
@Transactional(rollbackFor = AppException.class)
@Service
public class CouponBatchServiceImpl implements ICouponBatchService {
    private static final Logger LOGGER = Logger.getLogger(RedemptionServiceImpl.class);
    private static final String YYYY_MM_DD = "yyyy-MM-dd";
    @Autowired
    ICouponRedeemDao couponRedeemDaoImpl;
    @Autowired
    ICouponDao couponDao;
    @Autowired
    ICouponBatchDao couponBatchDao;
    @Autowired
    ICouponBatchLineDao couponBatchLineDao;
    @Autowired
    IMaintainCarPlateDao maintainCarPlateDao;
    @Autowired
    ITicKetDefineDao ticketDefineDao;
    @Autowired
    IMaintainMemberDao memberDao;
    @Autowired
    ISmContentService smContentService;
    @Autowired
    ICouponEligibilityService couponEligibilityService;
    
    /**
     * {@inheritDoc} overridden:
     * 
     * @Date : Sep 8, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#getCouponBatchAllList()
     **/
    @Override
    public CouponBatchDto getCouponBatchAllList(CouponBatchDto dto) throws AppException {
        dto.setCouponBatchList(couponBatchDao.getCouponBatchAllList(dto));
        return dto;
    }
    
    

    /**
     * {@inheritDoc} overridden:
     * 
     * @Date : Sep 9, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#addCouponBatch(com.cap.bts.crmdp.dealer.coupon.dto.CouponBatchDto)
     **/
    @Override
    public CouponBatch addCouponBatch(CouponBatch dto) throws AppException {
        return couponBatchDao.save(dto);
    }

    /**
     * {@inheritDoc} overridden:
     * 
     * @Date : Sep 9, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#deleteCouponBatch(java.lang.Long)
     **/
    @Override
    public void deleteCouponBatch(Long id) throws AppException {
        couponBatchDao.remove(id);
    }

    /**
     * {@inheritDoc} overridden:
     * 
     * @Date : Sep 9, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#getCouponBatchById(java.lang.Long)
     **/
    @Override
    public CouponBatch getCouponBatchById(Long id) throws AppException {
        return couponBatchDao.findById(id);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 9, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#updateCouponBatch(com.cap.bts.crmdp.dealer.coupon.domain.CouponBatch)
    **/
    @Override
    public void updateCouponBatch(CouponBatch cb) throws AppException {
        CouponBatch couponBatch=couponBatchDao.findById(cb.getId());
        if(couponBatch!=null){
            couponBatch.setDescription(cb.getDescription());
            couponBatch.setStartDate(cb.getStartDate());
            couponBatch.setEndDate(cb.getEndDate());
        }
        couponBatchDao.update(couponBatch);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 10, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#getCouponBatchLineListByBatchId(java.lang.Long)
    **/
    @Override
    public List<CouponBatchLine> getCouponBatchLineListByBatchId(Long batchId) throws AppException {
        return couponBatchLineDao.getCouponBatchLineListByBatchId(batchId);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 10, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#addGenerateCoupon(com.cap.bts.crmdp.dealer.coupon.domain.CouponBatchLine)
    **/
    @Override
    public CouponBatchLine addGenerateCoupon(CouponBatchLine couponBatchLine) throws AppException {
         couponBatchDao.findById(couponBatchLine.getCouponBatch().getId()).setIsBinded(1);
         return couponBatchLineDao.save(couponBatchLine);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 10, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#deleteGenerateCoupon(java.lang.Long)
    **/
    @Override
    public void deleteGenerateCoupon(Long id) throws AppException {
        couponBatchLineDao.remove(id);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 10, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#generateCoupon(java.util.List)
    **/
    @Override
    public Boolean generateCoupon(String generateInfo) throws AppException {
        return couponBatchLineDao.generateCoupon(generateInfo);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 15, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#redeemCoupon(com.cap.bts.crmdp.dealer.coupon.dto.RedeemCouponSubmitDto)
    **/
    @Override
    public Boolean redeemCoupon(RedeemCouponSubmitDto dto) throws AppException {
        Coupon coupon=couponDao.getCouponByCouponNumber(dto.getCoupon().getCouponNumber());
        CarPlateInfo carPlateInfo = maintainCarPlateDao.findById(dto.getCarId());
        if(coupon!=null){
        	//校验门店是否可以使用该优惠券
        	boolean applicableFlag = couponEligibilityService.checkeApplicableByDealerIdAndTicketId(UserUtil.getCurrentUser().getDealerId(), coupon.getTicketDefId());
        	
        	if((coupon.getRedeemDealerId() != null)
        			&& (coupon.getRedeemDealerId() != UserUtil.getCurrentUser().getDealerId())){
        		dto.setErrorMsg("该优惠券在您的门店不能使用!");
                return false;
        	}else{
        		if(!applicableFlag){
        			dto.setErrorMsg("该优惠券在您的门店不能使用!");
        			return false;
        		}
        	}
        	
            String now=DateUtils.format(new Date(), YYYY_MM_DD);
            String start=DateUtils.format(coupon.getCouponBatch().getStartDate(), YYYY_MM_DD);
            String end=DateUtils.format(coupon.getCouponBatch().getEndDate(), YYYY_MM_DD);
            //活动尚未开始
            if (now.compareTo(end)>0){
               dto.setErrorMsg("优惠券对应活动已经结束!");
               return false;
            }
            //活动已经结束
            if (now.compareTo(start)<0){
                dto.setErrorMsg("优惠券对应活动尚未开始!");
                return false;
            }
            
            /*
            //可以使用：更新使用相关字段使标该优惠券为使用状态
            List<CarPlateInfo> cpiList= maintainCarPlateDao.getCarPlateInfoListByCarPlateAndMemberId(dto.getCoupon().getRedeemMemberCar(), dto.getCarId());
            CarPlateInfo cpi=null;
            if(cpiList!=null&&!cpiList.isEmpty()){
                cpi=cpiList.get(0);
            }
            if(cpi!=null){
                coupon.setRedeemMemberId(cpi.getMemberId());
            }
            coupon.setRedeemDealerId(UserUtil.getCurrentUser().getDealerId());
            coupon.setRedeemMemberId(dto.getCarId());
            coupon.setRedeemDate(new Date());
            coupon.setRedeemMemberCar(dto.getCoupon().getRedeemMemberCar());
            coupon.setRedeemMemberName(dto.getCoupon().getRedeemMemberName());
            coupon.setRedeemMemberPhone(dto.getCoupon().getRedeemMemberPhone());
            
            */
            
          //是否用完
        	CouponForMARSDto marsDto = getCouponByCouponNumber(coupon.getCouponNumber());
    		List<CouponRedeem> couponRedeemList = getCouponRedeemListByCouponNumber(coupon.getCouponNumber());
    		if(couponRedeemList.size() >=  marsDto.getMaximunTimes()){
    			if(marsDto.getMaximunTimes() > 1){
    				dto.setErrorMsg("该优惠券已达到最大使用次数，请核对您输入的券号是否有误！");
    			}else{
    				dto.setErrorMsg("该优惠券已使用，请核对您输入的券号是否有误！");
    			}
    			
    			return false;
    		}
        	
            //可以使用：更新使用相关字段使标该优惠券为使用状态
        	
        	
        	CouponRedeem couponRedeem = new CouponRedeem();
        	
        	couponRedeem.setCouponId(coupon.getId());
        	couponRedeem.setCouponNumber(coupon.getCouponNumber());
            if(carPlateInfo != null){
            	couponRedeem.setRedeemMemberCarPlate(carPlateInfo.getCarPlate());
            	couponRedeem.setRedeemMemberCarId(carPlateInfo.getId());
            	
            	MemberInfo memberInfo = memberDao.findById(carPlateInfo.getMemberId());
            	if(memberInfo != null){
            		couponRedeem.setRedeemMemberName(memberInfo.getMemberName());
            		couponRedeem.setRedeemMemberPhone(memberInfo.getMobilePhone());
            		couponRedeem.setRedeemMemberId(memberInfo.getId());
            	}
            }
            
            
            couponRedeem.setRedeemDealerId(UserUtil.getCurrentUser().getDealerId());
            couponRedeem.setRedeemDate(new Date());
            //锁定状态
            couponRedeem.setMarsLockStatus("0");
            
            couponRedeemDaoImpl.save(couponRedeem);
            
        }else{
            Coupon checkCoupon=couponDao.checkCouponExist(dto.getCoupon().getCouponNumber());
            //判断优惠券是否已经使用，根据使用日期是否为空判断
            if(checkCoupon!=null){
                //该优惠券已使用
                dto.setErrorMsg("该优惠券已使用,使用日期:"+checkCoupon.getRedeemDate());
            }else{
                //该优惠券不存在
                dto.setErrorMsg("优惠券不存在!");
            }
           
            return false;
        }
        //ticket名称取得
        String tickeName="";
            Ticket t=ticketDefineDao.findById(coupon.getTicketDefId());
            if(t!=null){
                tickeName=t.getTicketName();
            }
        //成功时Msg存放在errorMsg里为弹出使用
        dto.setErrorMsg("市场活动:"+coupon.getCouponBatch().getBatchName()+",优惠券名称:"+tickeName+",使用成功！");
        
        if(carPlateInfo != null){
        	List<CarPlateInfo> cpiList= maintainCarPlateDao.getCarPlateInfoListByCarPlateAndMemberId(dto.getCoupon().getRedeemMemberCar(), carPlateInfo.getMemberId());
        	CarPlateInfo cpi=null;
        	if(cpiList!=null&&!cpiList.isEmpty()){
        		cpi=cpiList.get(0);
        	}
        	if(StringUtils.equals(t.getSmsRemind(),
        			CouponConstants.TICKET_TYPE_COUPON_SENDSMS_YES)){
        		sendSMSForRedeem(t,cpi);
        	}
        }
        return true;
    }
    
    private void sendSMSForRedeem(Ticket t,CarPlateInfo cpi){
        //send SMS Message
          if(t != null){
              //Send SMS
              Map<String, String> paraMap = new HashMap<String, String>();
              paraMap.put(SmsTemplateVariable.VARIABLE_REDEEM_LINE_NAME, t.getTicketName());
              SmsContentDetailDto smsDto = new SmsContentDetailDto();
              smsDto.setParaMap(paraMap);
              MemberInfo memberInfo = memberDao.findById(cpi.getMemberId());
              if (memberInfo != null && Utils.notEmpty(memberInfo.getMobilePhone())) {
                   smsDto.setDestMobile(Long.valueOf(memberInfo.getMobilePhone()));
                   smsDto.setTemplateNo(SmsTemplateNoConstants.TICKET_LINE_REDEEM_TEMPLATE_NO);
                   try {
                      smContentService.createSmsContent(smsDto);
                  } catch (AppException e) {
                      LOGGER.error("sendSMSForRedeem", e);
                  }
              }
          }
      }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2015年9月16日
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#getCouponBatchListwithQuery(com.cap.bts.crmdp.dealer.coupon.dto.CouponBatchDto)
    **/
    @Override
    public CouponBatchDto getCouponBatchListwithQuery(CouponBatchDto dto) throws AppException {
        dto.setCouponBatchList(couponBatchDao.getCouponBatchListwithQuery(dto));
        return dto;
    }
    
    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2015年9月16日
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#getExportCouponBatchListwithQuery(com.cap.bts.crmdp.dealer.coupon.dto.CouponBatchDto)
    **/
    @Override
    public CouponBatchDto getExportCouponBatchListwithQuery(CouponBatchDto dto) throws AppException {
        dto.setCouponBatchList(couponBatchDao.getExportCouponBatchListwithQuery(dto));
        return dto;
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 23, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#generateCSVfile(java.lang.Long)
    **/
    @Override
    public File generateCSVfile(Long batchId,Long ticketId) throws AppException {
            //a查询数据库卡表取得当前批次所有卡
            StringBuilder fileName=new StringBuilder();
            String ticketName=ticketDefineDao.findById(ticketId).getTicketName();
            fileName.append(couponBatchDao.findById(batchId).getBatchName())
            .append("_")
            .append(ticketName);
            List exportData = new ArrayList<Map>();
            Map map = new LinkedHashMap();
            map.put("1", "市场活动名称");
            map.put("2", "活动说明");
            map.put("3", "开始日期");
            map.put("4", "结束日期");
            map.put("5", "优惠券名称");
            map.put("6", "优惠券号");
            map.put("7", "生成日期");
            List<Coupon> couponList=couponDao.getCouponListByBatchId(batchId,ticketId);
            if(couponList!=null && !couponList.isEmpty()){
                for(Coupon c:couponList){
                    //传入卡列表(内容)以及批次信息(文件名称)生成CSV文件
                    Map row= new LinkedHashMap<String, String>();
                    row.put("1", c.getCouponBatch().getBatchName());
                    row.put("2", c.getCouponBatch().getDescription());
                    row.put("3", c.getCouponBatch().getStartDate().toString());
                    row.put("4", c.getCouponBatch().getEndDate().toString());
                    row.put("5", ticketName);
                    row.put("6", c.getCouponNumber());
                    row.put("7", c.getCreateDate().toString());
                    exportData.add(row);
                }
               
            }
        return  CSVUtils.createCSVFile(exportData, map, "/", fileName.toString());
    }



    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Sep 27, 2015
     * @see com.cap.bts.crmdp.dealer.coupon.service.ICouponBatchService#getExportCouponBatchAllList(com.cap.bts.crmdp.dealer.coupon.dto.CouponBatchDto)
    **/
    @Override
    public CouponBatchDto getExportCouponBatchAllList(CouponBatchDto dto) throws AppException {
        dto.setCouponBatchList(couponBatchDao.getExportCouponBatchAllList(dto));
        return dto;
    }
    
    @Override
    public CouponForMARSDto getCouponByCouponNumber(String couponNumber) throws AppException{
    	List<CouponForMARSDto> list = couponDao.getCouponListByCouponNumber(couponNumber);
    	
    	if(list == null || list.isEmpty()){
    		return null;
    	}
    	
    	return list.get(0);
    }
    
    @Override
    public AjaxResponse couponRedemption(CouponRedeemtionDto dto, AjaxResponse ajaxResponse) throws AppException{
    	//save data
    	Coupon coupon=couponDao.getCouponByCouponNo(dto.getCouponNo());
        if(coupon != null){
        	boolean applicableFlag = couponEligibilityService.checkeApplicableByDealerIdAndTicketId(UserUtil.getCurrentUser().getDealerId(), coupon.getTicketDefId());
        	
        	if((coupon.getRedeemDealerId() != null)
        			&& (coupon.getRedeemDealerId() != UserUtil.getCurrentUser().getDealerId())){
        		ajaxResponse.setSuccess(false);
        		ajaxResponse.setMessage("该优惠券在您的门店不能使用!");
                return ajaxResponse;
        	}else if(!applicableFlag){
        		ajaxResponse.setSuccess(false);
        		ajaxResponse.setMessage("该优惠券在您的门店不能使用!");
        		return ajaxResponse;
        	}
        	
            String now=DateUtils.format(new Date(), YYYY_MM_DD);
            String start=DateUtils.format(coupon.getCouponBatch().getStartDate(), YYYY_MM_DD);
            String end=DateUtils.format(coupon.getCouponBatch().getEndDate(), YYYY_MM_DD);
            //活动尚未开始
            if (now.compareTo(end)>0){
            	ajaxResponse.setSuccess(false);
            	ajaxResponse.setMessage("优惠券对应活动已经结束!");
            	
            	return ajaxResponse;
            }
            if (now.compareTo(start)<0){//活动已经结束
            	ajaxResponse.setSuccess(false);
            	ajaxResponse.setMessage("优惠券对应活动尚未开始!");
            	
            	return ajaxResponse;
            }
            
            
            	//是否用完
            	CouponForMARSDto marsDto = getCouponByCouponNumber(dto.getCouponNo());
        		List<CouponRedeem> couponRedeemList = getCouponRedeemListByCouponNumber(dto.getCouponNo());
        		if(couponRedeemList.size() >=  marsDto.getMaximunTimes()){
        			ajaxResponse.setSuccess(false);
        			if(marsDto.getMaximunTimes() > 1){
        				ajaxResponse.setMessage("该优惠券已达到最大使用次数，请核对您输入的券号是否有误！");
        			}else{
        				ajaxResponse.setMessage("该优惠券已使用，请核对您输入的券号是否有误！");
        			}
        		}else{
        			//可以使用：更新使用相关字段使标该优惠券为使用状态
        			CarPlateInfo carPlateInfo = maintainCarPlateDao.findById(dto.getCarId());
        			
        			CouponRedeem couponRedeem = new CouponRedeem();
        			
        			couponRedeem.setCouponId(coupon.getId());
        			couponRedeem.setCouponNumber(coupon.getCouponNumber());
        			if(carPlateInfo != null){
        				couponRedeem.setRedeemMemberCarPlate(carPlateInfo.getCarPlate());
        				couponRedeem.setRedeemMemberCarId(carPlateInfo.getId());
        			}
        			
        			MemberInfo memberInfo = memberDao.findById(dto.getMemberId());
        			if(memberInfo != null){
        				couponRedeem.setRedeemMemberName(memberInfo.getMemberName());
        				couponRedeem.setRedeemMemberPhone(memberInfo.getMobilePhone());
        			}
        			
        			couponRedeem.setRedeemDealerId(Long.valueOf(dto.getServerCenter()));
        			couponRedeem.setRedeemMemberId(dto.getMemberId());
        			couponRedeem.setRedeemDate(new Date());
        			//锁定状态
        			couponRedeem.setMarsLockStatus("1");
        			couponRedeem.setSoNumberRedeem(dto.getSoNumber());
        			
        			couponRedeemDaoImpl.save(couponRedeem);
        			
        			
        			//call Mars interface
        			dto.setCouponNo(couponRedeem.getId() +"");
        			CRM2MARS server = new CRM2MARS();
        			MarsResultDto resultDto = server.redeemCoupon(dto);
//	            
        			if(StringUtils.equals(resultDto.getStatusCode(), "0")){
        				throw new AppException("ERROR", resultDto.getResultMessage());
        			}
        			
        			//发送短信
					try {
						if (StringUtils.equals(marsDto.getSmsRemind(),
								CouponConstants.TICKET_TYPE_COUPON_SENDSMS_YES)) {
							// Send SMS
							Map<String, String> paraMap = new HashMap<String, String>();
							paraMap.put(SmsTemplateVariable.VARIABLE_REDEEM_LINE_NAME, marsDto.getTicketName());
							SmsContentDetailDto smsDto = new SmsContentDetailDto();
							smsDto.setParaMap(paraMap);

							if (memberInfo != null && Utils.notEmpty(memberInfo.getMobilePhone())) {
								smsDto.setDestMobile(Long.valueOf(memberInfo.getMobilePhone()));
								smsDto.setTemplateNo(SmsTemplateNoConstants.TICKET_LINE_REDEEM_TEMPLATE_NO);

								smContentService.createSmsContent(smsDto);
							}
						}
					} catch (AppException e) {
						LOGGER.error("sendSMSForRedeem", e);
					}
        			
            	
            }
            
        }
        
        return ajaxResponse;
    }
    
    @Override
    public List<CouponRedeem> getCouponRedeemListByCouponNumber(String couponNumber) throws AppException{
    	return couponRedeemDaoImpl.getByCouponNumber(couponNumber);
    }
}
